var prefix = jsctx + "/marketActivity";

var marketActivity = (function () {
    var chargeList = {

    };
    var radioIndex = 0;
    function init() {
        setTimeout(function () {//防止先于-读取缓存执行
            load();
        }, 10)
    };

    function reLoad() {
        $('#exampleTable').bootstrapTable('refresh');
    }

    function load() {
        $('#exampleTable')
            .bootstrapTable(
                {
                    method: 'get',
                    url: prefix + "/listPageMarketActivity",
                    iconSize: 'outline',
                    toolbar: '#exampleToolbar',
                    striped: false,
                    dataType: "json",
                    pagination: true,
                    singleSelect: false,
                    cache: false,
                    pageSize: 20,
                    pageList: [20],
                    pageNumber: 1,
                    sidePagination: "server",
                    queryParams: function (params) {
                        return {
                            limit: params.limit,
                            offset: (params.offset / params.limit) + 1,
                            activityName: $("#activityName").val().trim(),
                            activityType: $("#activityType").val().trim(),
                        };
                    },
                    columns: [
                        {
                            title: '#', field: '', width: '50', align: 'left',
                            formatter: function (value, row, index) {
                                return index + 1;
                            }
                        },
                        {field: 'activityName', title: '活动名称', width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                return '<a style="text-decoration:none;color: #007bff !important;" onclick="activityMember(' + row.marketActivityId + ')">' + value + '</a>';
                            }
                        },
                        {
                            field: 'activityType', title: '活动类型', width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                if (value == '1') {
                                    return '<span>充值活动</span>'
                                } else if (value == '3') {
                                    return '<span>满减活动</span>'
                                } else if (value == '4') {
                                    return '<span>满返活动</span>'
                                } else if (value == '5') {
                                    return '<span>拉新活动</span>'
                                }

                            }
                        },
                        {field: 'createdBy', title: '创建人', width: '100', align: 'center'},
                        {field: 'beginTime', title: '活动开始时间', width: '100', align: 'center'},
                        {field: 'endTime', title: '活动结束时间', width: '100', align: 'center'},
                        {
                            field: 'status', title: '活动状态', width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                if (value == '0') {
                                    return '<span>未开始</span>'
                                } else if (value == '1') {
                                    return '<span style="color: #0a6aa1">进行中</span>'
                                } else if (value == '2') {
                                    return '<span>已暂停</span>'
                                } else if (value == '3') {
                                    return '<span>已结束</span>'
                                }

                            }
                        },
                        {
                            title: '操作',
                            field: 'roleId',
                            width: '120', align: 'center',
                            class: 'operate-td',
                            formatter: function (value, row, index) {
                                var action = '';
                                action += '<a class="btn btn-success btn-sm ' + has_edit + '" href="#" title="详情" onclick="marketActivity.detail(\''
                                    + row.marketActivityId
                                    + '\')">详情</a> ';
                                if (row.status=='0'){
                                    action += '<a class="btn btn-success btn-sm ' + has_edit + '" href="#" title="开始" onclick="marketActivity.updateActivityStatus(\''
                                        + row.marketActivityId
                                        + '\',1)">开始</a> ';
                                }else if(row.status=='1'){//开始
                                    action += '<a class="btn btn-success btn-sm ' + has_edit + '" href="#" title="暂停" onclick="marketActivity.updateActivityStatus(\''
                                        + row.marketActivityId
                                        + '\',2)">暂停</a> ';
                                    action += '<a class="btn btn-success btn-sm ' + has_edit + '" href="#" title="暂停" onclick="marketActivity.updateActivityStatus(\''
                                        + row.marketActivityId
                                        + '\',3)">结束</a> ';
                                }else if(row.status=='2'){//暂停
                                    action += '<a class="btn btn-success btn-sm ' + has_edit + '" href="#" title="开始" onclick="marketActivity.updateActivityStatus(\''
                                        + row.marketActivityId
                                        + '\',1)">开始</a> ';
                                }
                                action += '<a class="btn btn-success btn-sm ' + has_delete + '" href="#" title="删除" onclick="marketActivity.deleteActivity(\''
                                    + row.marketActivityId
                                    + '\')">删除</a> ';
                                return action;
                            }
                        }
                    ]
                });
    }
    function updateActivityStatus(marketActivityId,_status) {
        layer.confirm('确定要更改状态？', {
            btn: ['确定', '取消']
        }, function (index) {
            $.ajax({
                url: prefix + "/updateActivityStatus",
                type: "post",
                data: {
                    'marketActivityId': marketActivityId,
                    'status': _status
                },
                success: function (data) {
                    layer.close(index);
                    if (data.status == 200) {
                        console.log(data)
                        layer.msg("更改成功");
                        reLoad();
                    } else {
                        layer.msg(data.message);
                    }
                }
            });
        })
    }



    function addMarketActivity() {
        location.href = prefix + "/addMarketActivity";
    }

    function editMarketActivity() {
        var marketActivityId = $("#marketActivityId").val();
        location.href = prefix + "/editMarketActivity/" + marketActivityId;
    }

    function marketActivityRecord() {
        location.href = prefix + "/marketActivityRecord";
    }

    function detail(id) {
        console.info(prefix);
        location.href = prefix + "/findById/" + id ;
    }

    function deleteActivity(marketActivityId) {
        layer.confirm('确定删除活动吗？', {
            btn: ['确定', '取消']
        }, function (index) {
            $.ajax({
                url: prefix + "/deleteActivity",
                type: "post",
                data: {
                    'marketActivityId': marketActivityId
                },
                success: function (data) {
                    layer.close(index);
                    if (data.status == 200) {
                        layer.msg("删除成功");
                        reLoad();
                    } else {
                        layer.msg(data.message);
                    }
                }
            });
        })
    }


    function goBack() {
        window.history.back();
    }

    function exportInfo() {
        $.fileDownload(prefix + "/exporListPageMarketActivity", { // 后台请求链接
            httpMethod: "get",　　　　　　　　// 请求方式
            contentType: 'application/json',　 // 请求头
            data: {　　　　　　　　　　　　　　　// 参数，左边为后台接收的参数名，右边为前端获取的值，
                offset: $('.active .page-link').text(),
                limit: $(".page-size").text(),

                activityName: $("#activityName").val().trim(),
                activityType: $("#activityType").val().trim(),
            },
            prepareCallback: function (url) {
                layer.msg("文件下载中...", {time: -1})
            },
            abortCallback: function (url) {
                // 异常终止
                layer.msg("文件下载异常！！");
            },
            successCallback: function (url) {
                layer.msg("文件下载成功！！", {time: 1500});
            },
            failCallback: function (data) {
                var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                layer.msg(JSON.parse(str).message);
            }
        })
    };

    return {
        init: init,
        goBack: goBack,
        reLoad: reLoad,
        load: load,
        detail: detail,
        updateActivityStatus: updateActivityStatus,
        addMarketActivity: addMarketActivity,
        deleteActivity: deleteActivity,
        exportInfo:exportInfo,
        activityMember:activityMember
    };
})();


var addMarketActivity = (function () {
    var chargeDivNum = 0;
    var reductionDivNum = 0;
    var returnDivNum = 0;
    var newDivNum = 0;
    var initTicket = [];
    function init() {
        //初始化 卡券数据

        validateRule();
        initData();
    };

    function initData() {
        $.ajax({
            "url":"/tenantTicketType/getAllData",
            "type": "POST",
            "data": {
            },
            "success": function (data) {
                initTicket = data;

            }
        })

    }
    function getCheckedRoles() {
        var adIds = "";
        $("input:checkbox[name=role]:checked").each(function (i) {
            if (0 == i) {
                adIds = $(this).val();
            } else {
                adIds += ("," + $(this).val());
            }
        });
        return adIds;
    }

    var isajaxsend = true;

    function save() {
        if (isajaxsend) {
            var formData = new FormData($("#frmMarketActivity")[0]);
            //var searchForm = formData.serializeArray();
            /*var a = $("#frmMarketActivity").serializeArray();
            var o = {};
            $.each(a, function() {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });*/

            //富文本
            //alert(contenthtml);
            /*          var participateUser = $("#userIds").val();
                      formData.append("participateUser",participateUser);*/
            formData.append("content",contenthtml);
            var activityType = $("#activityTypeId").val();
            var chargeList = [];
            var redutionList = [];
            var returnList = [];
            var newList = [];
            switch (activityType) {
                case '1' :
                    var chargeInfo = {};
                    var radioVal = $("input[name=chargeRadio_cz_0]:checked").val();
                    if (radioVal=='0'){
                        chargeInfo.chargeRadio_cz = radioVal;
                        chargeInfo.chargeAmount_cz = document.getElementsByName("chargeAmount_cz_0")[0].value;
                        chargeInfo.awardAmount_cz = $("#awardAmount_cz_0").val();
                        chargeInfo.tickettypeId_cz = 0;
                        chargeList.push(chargeInfo);
                    }else{
                        chargeInfo.chargeRadio_cz = radioVal;
                        chargeInfo.chargeAmount_cz = document.getElementsByName("chargeAmount_cz_0")[1].value;
                        chargeInfo.awardAmount_cz = 0;
                        chargeInfo.tickettypeId_cz = $("#tickettypeId_cz_0").val();

                        chargeList.push(chargeInfo);
                    }
                    if(chargeDivNum==1){
                        var chargeInfo1 = {};
                        var radioVal1 = $("input[name=chargeRadio_cz_1]:checked").val();
                        if (radioVal1=='0'){
                            chargeInfo1.chargeRadio_cz = radioVal1;
                            chargeInfo1.chargeAmount_cz = document.getElementsByName("chargeAmount_cz_1")[0].value;
                            chargeInfo1.awardAmount_cz = $("#awardAmount_cz_1").val();
                            chargeInfo1.tickettypeId_cz = 0;
                            chargeList.push(chargeInfo1);
                        }else{
                            chargeInfo1.chargeRadio_cz = radioVal1;
                            chargeInfo1.chargeAmount_cz = document.getElementsByName("chargeAmount_cz_1")[1].value;
                            chargeInfo1.awardAmount_cz = 0;
                            chargeInfo1.tickettypeId_cz = $("#tickettypeId_cz_1").val();
                            chargeList.push(chargeInfo1);
                        }
                    }
                    formData.append("chargeLstStr",JSON.stringify(chargeList));
                    break;
                case '3' :
                    // $("#fullRedutionId").show();
                    var redutionInfo = {};
                    redutionInfo.orderAmount_mj = $("#orderAmount_mj_0").val();
                    redutionInfo.awardAmount_mj = $("#awardAmount_mj_0").val();
                    redutionList.push(redutionInfo);
                    if (reductionDivNum==1){
                        var redutionInfo1 = {};
                        redutionInfo1.orderAmount_mj = $("#orderAmount_mj_1").val();
                        redutionInfo1.awardAmount_mj = $("#awardAmount_mj_1").val();
                        redutionList.push(redutionInfo1);
                    }
                    formData.append("redutionLstStr",JSON.stringify(redutionList));
                    console.log("切换满减活动拉33333");
                    break;
                case '4' :
                    //$("#fullReturnId").show();
                    var returnInfo = {};
                    returnInfo.orderAmount_mf = $("#orderAmount_mf_0").val();
                    returnInfo.tickettypeId_mf = $("#tickettypeId_mf_0").val();
                    returnList.push(returnInfo);
                    if (returnDivNum==1){
                        var returnInfo1 = {};
                        returnInfo1.orderAmount_mf = $("#orderAmount_mf_1").val();
                        returnInfo1.tickettypeId_mf = $("#tickettypeId_mf_1").val();
                        returnList.push(returnInfo1);
                    }
                    formData.append("returnLstStr",JSON.stringify(returnList));
                    console.log("切换满返活动拉44444");
                    break;
                case '5' :
                    // $("#pullNewId").show();
                    var newInfo = {};
                    var radioVal = $("input[name=pullNewRadio_lx_0]:checked").val();
                    if (radioVal=='0'){
                        newInfo.pullNewRadio_lx = radioVal;
                        newInfo.pullNew_lx = document.getElementsByName("pullNew_lx_0")[0].value;
                        newInfo.awardAmount_lx = $("#awardAmount_lx_0").val();
                        newInfo.ticketTypeId_lx = 0;
                    }else{
                        newInfo.pullNewRadio_lx = radioVal;
                        newInfo.pullNew_lx = document.getElementsByName("pullNew_lx_0")[1].value;
                        newInfo.awardAmount_lx = 0;
                        newInfo.ticketTypeId_lx = $("#ticketTypeId_lx_0").val();
                    }
                    newList.push(newInfo);
                    if(chargeDivNum==1){
                        var newInfo1 = {};
                        var radioVal1 = $("input[name=pullNewRadio_lx_1]:checked").val();
                        if (radioVal1=='0'){
                            newInfo1.pullNewRadio_lx = radioVal1;
                            newInfo1.pullNew_lx = document.getElementsByName("pullNew_lx_1")[0].value;
                            newInfo1.awardAmount_lx = $("#awardAmount_lx_1").val();
                            newInfo1.ticketTypeId_lx = 0;
                        }else{
                            newInfo1.pullNewRadio_lx = radioVal1;
                            newInfo1.pullNew_lx = document.getElementsByName("pullNew_lx_1")[1].value;
                            newInfo1.awardAmount_lx = 0;
                            newInfo1.ticketTypeId_lx = $("#ticketTypeId_lx_1").val();
                        }
                        newList.push(newInfo1);
                    }
                    formData.append("newLstStr",JSON.stringify(newList));
                    console.log("切换拉新活动拉55555");
                    break;
            }
            $("#roleIds").val(getCheckedRoles());
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + "/saveActivity",
                data: formData,
                processData: false,
                contentType: false,
                async: false,
                beforeSend: function () {
                    isajaxsend = false
                },
                error: function (request) {
                    isajaxsend = true
                    parent.layer.alert("Connection error");
                },
                success: function (data) {
                    if (data.status == 200) {
                        isajaxsend = true
                        parent.layer.msg("操作成功");
                        window.history.back();
                    } else {
                        isajaxsend = true
                        parent.layer.alert(data.message)
                    }

                }
            });
        }
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#frmMarketActivity").validate({
            rules: {
                activityName: {
                    required: true,
                },
                beginTime: {
                    required: true
                },
                endTime: {
                    required: true
                }

            },
            messages: {
                activityName: {
                    activityName: icon + "请输入活动名称",
                },
                beginTime: {
                    required: icon + "请选择开始时间",
                },
                endTime: {
                    required: icon + "请输选择结束时间",
                }
            },
            submitHandler: function (form) {
                save();
            }
        })
    }

    function  addPullNew() {
        if(newDivNum==1){
            alert("最大添加一行");
            return;
        }
        newDivNum += newDivNum+1;
        var str = '<div id="pullNewInputs" >\n' +
            '\t<input type="radio" name="pullNewRadio_lx_'+newDivNum+'" value="0" checked><span>拉新人数满\n' +
            '\t<input type="text" name="pullNew_lx_'+newDivNum+'" >奖励<input type="text" name="awardAmount_lx_'+newDivNum+'" id="awardAmount_lx_'+newDivNum+'" >(元)</span></inpt>\n' +
            '\t<input type="button" onclick="addMarketActivity.removeParent(this,\'new_type\')" value="[-]" /><br>\n' +
            '\t<input type="radio" name="pullNewRadio_lx_'+newDivNum+'" value="1" ><span>拉新人数满<input type="text" name="pullNew_lx_'+newDivNum+'" >\n' +
            '\t奖励<select  name="ticketTypeId_lx_'+newDivNum+'" id="ticketTypeId_lx_'+newDivNum+'" class="form-control" placeholder="选择卡券" lay-search="">\n' +
            '\t\t\t   <option value="" selected="selected">请选择</option>';
        for (var i=0;i<initTicket.length;i++)
        {
            str += '<option value="'+initTicket[i].ticketTypeId+'">'+initTicket[i].ticketName+'|'+initTicket[i].discountTypeName+'|'+initTicket[i].userTypeName+'|'+initTicket[i].discountDesc+'</option>';
        }
        str+=' </select>\n' +
            '     </span></inpt>\n' +
            '       </div>';
        $('#pullNewInputs').append(str);
    }
    function  addFullRedution() {
        if(reductionDivNum==1){
            alert("最大添加一行");
            return;
        }
        reductionDivNum = reductionDivNum+1;
        var str = '<div id="fullReductionInputs" >\n' +
            '            <span>订单金额满<input type="text" name="orderAmount_mj_'+reductionDivNum+'"  id="orderAmount_mj_'+reductionDivNum+'" >' +
            '减<input type="text" name="awardAmount_mj_'+reductionDivNum+'"   id="awardAmount_mj_'+reductionDivNum+'">(元)</span></inpt>\n' +
            '        <input type="button" onclick="addMarketActivity.removeParent(this,\'reduction_type\')" value="[-]" /><br>\n' +
            '            </div>';
        $('#fullReductionInputs').append(str);
    }
    function  addFullReturn() {
        if(returnDivNum==1){
            alert("最大添加一行");
            return;
        }
        returnDivNum = returnDivNum+1;
        var str = '<div id="fullReturnInputs" style="word-break: normal">\n' +
            '                                <span>订单金额满<input type="text" name="orderAmount_mf_'+returnDivNum+'" id="orderAmount_mf_'+returnDivNum+'" >奖励' +
            '        <input type="button" onclick="addMarketActivity.removeParent(this,\'ruturn_type\')" value="[-]" />\n' +
            '                                <select  name="tickettypeId_mf_'+returnDivNum+'" id="tickettypeId_mf_'+returnDivNum+'" class="form-control" placeholder="选择卡券" lay-search="">\n' +
            '                                           <option value="" selected="selected">请选择</option>';
        for (var i=0;i<initTicket.length;i++)
        {
            str += '<option value="'+initTicket[i].ticketTypeId+'">'+initTicket[i].ticketName+'|'+initTicket[i].discountTypeName+'|'+initTicket[i].userTypeName+'|'+initTicket[i].discountDesc+'</option>';
        }
        str+= '</select>' +
            '       </span>' +
            '          </div>';

        $('#fullReturnInputs').append(str);
    }

    function addCharge() {
        if(chargeDivNum==1){
            alert("最大添加一行");
            return;
        }
        chargeDivNum = chargeDivNum+1;
        var str = '<div id="chargeInputs" >\n' +
            '     <input type="radio" name="chargeRadio_cz_'+chargeDivNum+'" value="0" checked="checked">\n' +
            '         <span>充值金额满<input type="text" name="chargeAmount_cz_'+chargeDivNum+'" >奖励'+
            '             <input type="text" name="awardAmount_cz_'+chargeDivNum+'" id="awardAmount_cz_'+chargeDivNum+'">(元)</span></inpt>\n' +
            /* '     <input type="button" onclick="addCharge1()" value="[+]" />\n' +*/
            '         <input type="button" onclick="addMarketActivity.removeParent(this,\'charge_type\')" value="[-]" /><br>\n' +
            '     <input type="radio" name="chargeRadio_cz_'+chargeDivNum+'" value="1" >\n' +
            '         <span>充值金额满<input type="text" name="chargeAmount_cz_'+1+'" >\n' +
            '              奖励<select  name="tickettypeId_cz_'+chargeDivNum+'" id="tickettypeId_cz_'+chargeDivNum+'" class="form-control" placeholder="选择卡券" lay-search="">\n'+
            '                <option value="" selected="selected">请选择</option>\n' ;
        for (var i=0;i<initTicket.length;i++)
        {
            str += '<option value="'+initTicket[i].ticketTypeId+'">'+initTicket[i].ticketName+'|'+initTicket[i].discountTypeName+'|'+initTicket[i].userTypeName+'|'+initTicket[i].discountDesc+'</option>';
        }
        /*  /'                <c:forEach items="${ticketInfos}" var="info">\n' +
          '                    <option value="${info.ticketTypeId}">${info.ticketName}|${info.discountTypeName}|${info.userTypeName}|${info.discountDesc}\n' +
          '                    </option>\n' +
          '                </c:forEach>\n' +*/
        str +='            </select>\n' +
            '         </span>\n' +
            '     </inpt>\n' +
            ' </div>';

        $('#chargeInputs').append(str);
    }

    function removeParent(e,type) {
        switch (type) {
            case 'charge_type' :
                chargeDivNum = chargeDivNum-1;
                break;
            case 'reduction_type' :
                reductionDivNum = reductionDivNum-1;
                break;
            case 'ruturn_type' :
                returnDivNum = returnDivNum-1;
                break;
            case 'new_type' :
                newDivNum = newDivNum-1;
                break;
        }
        $(e).parent().remove()
    }

    function removeReduction(e) {
        reductionDivNum = reductionDivNum-1;
        $(e).parent().remove()
    }

    $.fn.serializeJson=function(){
        var serializeObj={};
        var array=this.serializeArray();
        // var str=this.serialize();
        $(array).each(function(){ // 遍历数组的每个元素
            if(serializeObj[this.name]){ // 判断对象中是否已经存在 name，如果存在name
                if($.isArray(serializeObj[this.name])){
                    serializeObj[this.name].push(this.value); // 追加一个值 hobby : ['音乐','体育']
                }else{
                    // 将元素变为 数组 ，hobby : ['音乐','体育']
                    serializeObj[this.name]=[serializeObj[this.name],this.value];
                }
            }else{
                serializeObj[this.name]=this.value; // 如果元素name不存在，添加一个属性 name:value
            }
        });
        return serializeObj;
    };

    return {
        init: init,
        initData: initData,
        save: save,
        addPullNew:addPullNew,
        addFullRedution:addFullRedution,
        addFullReturn:addFullReturn,
        removeParent:removeParent,
        addCharge:addCharge,
    };
})();
function activityMember(marketActivityId){
    if (marketActivityId == null || marketActivityId == undefined){
        marketActivityId = $("#memberFind").data("activityId");
    }else{
        $("#memberFind").data("activityId",marketActivityId);
    }
    layer.open({
        type: 1,
        title:"参与活动用户",
        content: $("#windowBox"),
        success: function(layero, index){
            $("#windowBox").show();
        },
        cancel: function(index, layero){
            setTimeout(function(){
                $("#windowBox").hide();
            },500)
        },
        area: ['1300px', '940px']
    });
    $(".layui-layer-shade:eq(1)").remove()
    console.log("marketActivityId---" + marketActivityId);
    laydate.render({
        elem: '#registerTime' //指定元素
    });
    setTimeout(function () {//防止先于-读取缓存执行
        $("#activityMember").bootstrapTable('destroy');
        $('#activityMember')
            .bootstrapTable(
                {
                    method: 'get',
                    url: prefix + "/listPageActivityMemberInfo",
                    data:{marketActivityId:marketActivityId},
                    iconSize: 'outline',
                    toolbar: '#exampleToolbar',
                    striped: false,
                    dataType: "json",
                    pagination: true,
                    singleSelect: false,
                    cache: false,
                    pageSize: 10,
                    pageList: [20],
                    pageNumber: 1,
                    sidePagination: "server",
                    queryParams: function (params) {
                        return {
                            limit: params.limit,
                            offset: (params.offset / params.limit) + 1,
                            marketActivityId:marketActivityId,
                            consumpNum:$("#consumpNum").val().trim(),
                            changeNum:$("#changeNum").val().trim(),
                            memberType:$("#memberType").val().trim(),
                            memberAddress:$("#memberAddress").val().trim(),
                            memberLevel:$("#memberLevel").val().trim(),
                            registerTime:$("#registerTime").val().trim()
                        };
                    },
                    columns: [
                        {
                            title: '#', field: '', width: '50', align: 'left',
                            formatter: function (value, row, index) {
                                return index + 1;
                            }
                        },
                        {field: 'memberId', title: '用户ID', width: '100', align: 'center'},
                        {field: 'memberName', title: '昵称', width: '100', align: 'center'},
                        {field: 'memberVx', title: '微信', width: '100', align: 'center'},
                        {field: 'memberPhone', title: '手机号', width: '100', align: 'center'},
                        {field: 'memberOrder', title: '订单编号', width: '100', align: 'center'},
                        {
                            field: 'memberStatus', title: '状态', width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                return "<input type=\"checkbox\" style=\"width: 40px !important;\" onclick=\"openOrClose('" + row.memberId +"','" + value + "')\" "+ (value==0?'checked':'') +">";
                            }
                        },
                        {
                            field: 'memberType', title: '用户类型', width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                if (value == '0') {
                                    return '<span>个人用户</span>'
                                } else if (value == '2') {
                                    return '<span style="color: #0a6aa1">企业子帐户</span>'
                                } else if (value == '3') {
                                    return '<span>互联互通用户</span>'
                                } else if (value == '10') {
                                    return '<span>会员</span>'
                                }

                            }
                        },
                        {field: 'memberAddress', title: '地区', width: '100', align: 'center'},
                        {field: 'memberLevel', title: '会员等级', width: '100', align: 'center'},
                        {field: 'memberRegisterTime', title: '注册时间', width: '100', align: 'center'},
                        {field: 'memberLastLogin', title: '最近登录时间', width: '100', align: 'center'}

                    ]
                });
    }, 10)

}
function rest(){
    $("#memberType").val("")
    $("#registerTime").val("")
    $("#consumpNum").val("")
    $("#changeNum").val("")
    $("#memberAddress").val("")
    $("#memberLevel").val("")
}
function openOrClose(memberId,status) {
    //修改操作
    console.log(memberId + " ---6" + status)
    $.ajax({
        type: "post",
        dataType: "json",
        async: false,
        url: jsctx + "/member/updateMemberStatus",
        data: {
            status: status == "0" ? "1" : "0",
            id: memberId
        }
    });
}